.github: add better labeller#33131
Conversation
| const headSha = context.payload.workflow_run.head_sha; | ||
| const result = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| commit_sha: headSha, | ||
| }); | ||
| if (result.data.length === 0) { | ||
| core.warning('No PR found for commit ' + headSha); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Assuming this works, I like that it's not reliant on outputs from the contributor-controlled workflow, so the user has no control over how the labelling Action gets triggered (e.g. they can't make it trigger on a different PR), just whether or not it does 👍
There was a problem hiding this comment.
@khancyr is it even possible for a commit hash to be looked up in a repo it doesn't exist in / hasn't been merged into?
It seems the endpoint doesn't work if the target owner and repo are specified, which likely explains the test failure.
It does work if we specify the PR author's username and repo name, but we can't do that in an Action being run isolated in the target, because we don't know what those values are without passing them in (in which case we're back to the artifacts approach or similar).
There was a problem hiding this comment.
Fixed , we indeed needed to look at OP repo to access it
|
@khancyr I've raised a PR against your If you could approve the labels trigger workflow run (and cancel the rest if relevant) that would be helpful, so we can see if an external contributor still gets the labels applied correctly :-) |
| @@ -1,22 +1,60 @@ | |||
| name: ci | |||
There was a problem hiding this comment.
| name: ci | |
| name: Labels Apply |
Summary
alternative to #33127. Don't use pull_request_target nor artefact !
Result can be seen here :
khancyr#28
Classification & Testing (check all that apply and add your own)
Description